package com.qfedu.controller;

import com.alibaba.fastjson.JSON;
import com.qfedu.entity.Brand;
import com.qfedu.service.BrandService;
import com.qfedu.service.impl.BrandServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Date 2023/10/9 19:24
 */

@WebServlet("/brand/list.do")
public class BrandListController extends HttpServlet {
    private BrandService service=new BrandServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Brand> all = service.findAll();
        String json = JSON.toJSONString(all);
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
